
#include "GC.h"

#include <variant_map.h>
#include <typeinfo>

using namespace Riccsson::System;

//------------------------------------------------------------------------------
GC_PTR<string> GC::ReportMemory()
{
	s_instancesCounter.reset();

	// Loop all instances type in GC_PTR.
	std::map2<void*, int>::my_struct<void*>* key = null;

	string output("Memory report: \n");

	while (key = s_instancesCounter.next())
	{
		var item = s_instancesCounter[key->id];

		const char* rawName = typeid(key->id).raw_name();

		string line(string("Class: '") + rawName + "' count: " + item);

		output += line + "\n";
	}

	return new string(output);
}